function TreeNode(width, height, angle, age, parent){
	this.width = width;
	this.height = height;
	this.angle = angle;
	this.age = age;
	this.parent = parent;
	this.children = new Array();	
	
	//Add-Child
	this.addChild = function(child) {	
			
		this.children.push(child);			
	};
	
	//Test-Print-Tree
	this.printTree = function() {
		
		alert('width:'+this.width+' height:'+this.height);
		
		for(var i = 0; i < this.children.length;i++){
			this.children[i].printTree();	
		};		
	};
	
	//Let it grow
	this.grow = function() {
		
		//alert('grow');
		
		var initheight = 4;
		var initwidth = 1;
		var spawnheight = 20;
		var heightgain = 2;
		var widthgain = 0.5;
				
		this.height = this.height + heightgain;
		this.width = this.width + widthgain;
						
		
		
		if((this.children.length==0)&&(this.height>=spawnheight)){
		//	alert('spawny '+this.children.length+' '+this.height);
			this.addChild(new TreeNode(initwidth,initheight,20,1,1));
			this.addChild(new TreeNode(initwidth,initheight,340,1,1));	
					
		}
		else{
			for(var i = 0; i < this.children.length;i++){
			this.children[i].grow();	
			}
		}		
	};
	
	return this;
    
}





